Hi, I have parent objects 1,2,3... so on. each of these have child objects 1.1,1.2....1.10 and 2.1,2.2...2.10 respectively. Is there any script to copy the values of an attribute in the parent object to all the child objects. i tried using the getParent function,but it does not work Gsquare - Fri Nov 25 01:50:57 EST 2016 |
Re: Copy values to child object Such a script is easy to make. Maybe something like this (untested).
void getChilds (Object o, Skip sk, int &index) {
Object oChild; for oChild in all o {
if (isDeleted o) continue;
put(sk, index++, oChild);
getChilds(oChild, sk, index);
}
return sk;
}
Skip getChilds (Object o) {
Skip sk = create();
int index = 0;
getChilds(o, sk, index);
return sk;
}
Skip sk = getChilds(current Object);
Object o; for o in sk do set(o."MyAttribute", (current Object)."MyAttribute");
delete sk
Regards, Mathias |
Re: Copy values to child object There's also a pretty easy, (non-DXL) way to do this. Filter the view in that module to only include the Parent and Child objects you described. Then select one of the parent objects with the desired value. right-click on that object and bring up the Properties dialog. In that dialog, select the desired attribute and click the "View/Edit" button. In the Attribute Value dialog that appears, you have the option to "Apply to:"..."Objects in current view". If you select that option, all the objects in your filtered view will have that value applied to them. Another option is when you create an attribute, consider checking the box for "Inherit value" under "Attribute features:". By default, that makes the attribute value selected for any Parent object inherited as the value for its child objects. |